package com.codeforces.cf584;

import java.util.Scanner;

public class B {
    Scanner in = new Scanner(System.in);
    void solve(){
        int t = in.nextInt();
        while (t-- > 0) {
            int n = in.nextInt(),k = in.nextInt();
            int len = n * k;
            int[] arr = new int[len];
            long sum = 0;
            for(int i = 0;i < len;i++){
                arr[i] = in.nextInt();
            }
            int mid = n - ((n - 1)  / 2);
            int first = len  - mid;
            for(int i = 0;i < k;i++){
                sum += arr[first];
                first -= mid;
            }
            System.out.println(sum);
        }
    }

    public static void main(String[] args) {
        B s = new B();
        s.solve();
    }
}
